package com.night.icm.service.base.mapper;

import com.night.icm.model.base.ConfigurationInfoDTO;
import com.night.icm.persistence.base.entity.ConfigurationInfo;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ReportingPolicy;

import java.util.List;

/**
 * ConfigurationInfoMapper
 *
 * @author Liao ZhiYong
 * @date 2020/1/25
 */
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ConfigurationInfoMapper {

    /**
     * DTO转实体
     *
     * @param configurationInfoDTO DTO
     * @return 实体
     */
    ConfigurationInfo toEntity(ConfigurationInfoDTO configurationInfoDTO);

    /**
     * 实体转DTO
     *
     * @param save 实体
     * @return DTO
     */
    ConfigurationInfoDTO toDTO(ConfigurationInfo save);

    /**
     * 实体集转为DTO集
     *
     * @param content 实体集
     * @return DTO集
     */
    @IterableMapping(qualifiedByName = "toDTO")
    List<ConfigurationInfoDTO> toList(List<ConfigurationInfo> content);

    /**
     * 更新一个已经存在的实体数据
     *
     * @param configurationInfoDTO 存在的dto
     * @param configurationInfo    更新后的实体
     */
    void updateEntity(ConfigurationInfoDTO configurationInfoDTO, @MappingTarget ConfigurationInfo configurationInfo);
}
